<template>
  <a-card :bordered="false">
      <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="应聘者">
              <a-input placeholder="请输入应聘者" v-model="queryParam.name"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="应聘岗位">
              <!-- <j-search-select-tag  v-model="queryParam.applyPosition" dict="sys_position,name,id"  :async="true"/> -->
              <j-search-select
                v-model="queryParam.applyPosition"
                dict="sys_position,name,id,del_flag = 0 and audit_status=2"
              />
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="面试情况">
              <j-dict-select-tag placeholder="请选择面试情况" v-model="queryParam.interviewStatus" dictCode="	interview_info_status"/>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="面试结果">
              <j-dict-select-tag placeholder="请选择面试结果" v-model="queryParam.interviewResult" dictCode="interview_result"/>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <!-- <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
              </a> -->
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <!-- <a-button @click="handleAdd" type="primary" icon="plus" :disabled="isDisabledAuth('erpHrApplyRegisterBill:add')">新增</a-button> -->
      <!-- <a-button type="primary" icon="download" @click="handleExportXls('应聘登记表')" :disabled="isDisabledAuth('erpHrApplyRegisterBill:export')">导出</a-button>
      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
        <a-button type="primary" icon="import" :disabled="isDisabledAuth('erpHrApplyRegisterBill:import')">导入</a-button>
      </a-upload> -->
      <!-- 高级查询区域 -->
      <!--<j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>-->
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel" :disabled="isDisabledAuth('erpHrApplyRegisterBill:delete')"><a-icon type="delete"/>删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
      </a-dropdown>
      <a-popover title="自定义列" trigger="click" placement="leftBottom">
        <template slot="content">
          <a-checkbox-group @change="onColSettingsChange" v-model="settingColumns" :defaultValue="settingColumns">
            <a-row>
              <template v-for="(item,index) in defColumns">
                <template v-if="item.key!='rowIndex'&& item.dataIndex!='action'">
                  <a-col :span="12"><a-checkbox :value="item.dataIndex">{{ item.title }}</a-checkbox></a-col>
                </template>
              </template>
            </a-row>
          </a-checkbox-group>
        </template>
        <a style="float: right;"><a-icon type="setting" :style='iconStyle'/></a>
      </a-popover>
    </div>

    <!-- table区域-begin -->
    <div>
      <!-- <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div> -->

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        :components="draggableComponent"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
       
        class="j-table-force-nowrap"
        :customRow="customRow"
        @change="handleTableChange">
        <a slot="name" slot-scope="text, record" @click="getDetail(record.id)">{{ text }}</a>
        <template slot="status" slot-scope="status">
           <a-badge :status="status | statusTypeFilter" :text="status | statusFilter"/>
        </template>
        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
            <a-button
                class="ruleButton"
                :ghost="true"
                type="primary"
                icon="edit"
                @click="handleEdit(record)"
                :disabled="isDisabledAuth('erpHrApplyRegisterBill:edit')"
        />
        <!-- <a-divider type="vertical"/>
        <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
            <a-button
                    class="ruleButton"
                    :ghost="true"
                    type="primary"
                    icon="delete"
                    :disabled="isDisabledAuth('erpHrApplyRegisterBill:delete')"/>
        </a-popconfirm> -->
        <template v-if="record.interviewStatus=='0'">
        <a-divider type="vertical"/>
          <a-popconfirm title="确定处理初试吗?" @confirm="() => handleInterview(record.id,1)"  :disabled="isDisabledAuth('erpHrApplyRegisterBill:handleInterviewFirst')">
             <a-button type="primary" size="small"  :disabled="isDisabledAuth('erpHrApplyRegisterBill:handleInterviewFirst')">初试</a-button>
          </a-popconfirm>
        </template>
        <template v-if="record.interviewStatus=='1'  && record.firstResult!='2'">
        <a-divider type="vertical"/>
          <a-popconfirm title="确定处理复试吗?" @confirm="() => handleInterview(record.id,2)"  :disabled="isDisabledAuth('erpHrApplyRegisterBill:handleInterviewSecond')">
            <a-button type="primary" size="small" :disabled="isDisabledAuth('erpHrApplyRegisterBill:handleInterviewSecond')">复试</a-button>
          </a-popconfirm>
        </template>
        <template v-if="record.interviewStatus=='2'  && record.secondResult!='2' ">
        <a-divider type="vertical"/>
          <a-popconfirm title="确定处理评价吗?" @confirm="() => handleInterview(record.id,3)"  :disabled="isDisabledAuth('erpHrApplyRegisterBill:handleInterviewEnd')">
              <a-button type="primary" size="small" :disabled="isDisabledAuth('erpHrApplyRegisterBill:handleInterviewEnd')">评价</a-button>
          </a-popconfirm>
        </template>
        </span>

      </a-table>
    </div>
    <erp-hr-apply-register-bill-modal ref="modalForm" @ok="modalFormOk"></erp-hr-apply-register-bill-modal>
    <erp-hr-apply-result-info-modal ref="applyInfo" @ok="modalFormOk"></erp-hr-apply-result-info-modal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import ErpHrApplyRegisterBillModal from './modules/ErpHrApplyRegisterBillModal'
  import ErpHrApplyResultInfoModal from './modules/ErpHrApplyResultInfoModal'
  import {DisabledAuthFilterMixin} from '@/mixins/DisabledAuthFilterMixin'
  import JSearchSelect from './modules/JSearchSelect.vue'

  export default {
    name: 'ErpHrApplyRegisterBillList',
    mixins:[JeecgListMixin, mixinDevice, DisabledAuthFilterMixin],
    components: {
      ErpHrApplyRegisterBillModal,
      ErpHrApplyResultInfoModal,
      JSearchSelect
    },
    data () {
      return {
        description: '应聘登记表管理页面',
        //表头
        columns:[],
        //列设置
        settingColumns:[],
        // 列定义
        defColumns: [
          {
            title: '序号',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'姓名',
            align:"center",
            dataIndex: 'name',
            width:100,
            scopedSlots: { customRender: 'name' },
          },
          {
            title:'性别',
            align:"center",
            width:60,
            dataIndex: 'gender_dictText',
          },
          {
            title:'应聘岗位',
            align:"center",
            width:200,
            dataIndex: 'applyPosition_dictText',
          },
          {
            title:'工作经验',
            align:"center",
            width:200,
            dataIndex: 'workTime_dictText',
          },
          {
            title:'面试日期',
            align:"center",
            width:200,
            dataIndex: 'actualInterviewTime',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,16):text)
            }
          },
          {
            title:'面试结果',
            align:"center",
            width:150,
            dataIndex: 'interviewResult_dictText',
          },
          {
            title:'人才标签',
            align:"center",
            dataIndex: 'talentLabel_dictText',
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:150,
            scopedSlots: {
            filterDropdown: 'filterDropdown',
            filterIcon: 'filterIcon',
            customRender: 'action' }
          }
        ],
        url: {
          list: "/api/erp/hr/apply/erpHrApplyRegisterBill/list2",
          delete: "/api/erp/hr/apply/erpHrApplyRegisterBill/delete",
          deleteBatch: "/api/erp/hr/apply/erpHrApplyRegisterBill/deleteBatch",
          exportXlsUrl: "/api/erp/hr/apply/erpHrApplyRegisterBill/exportXls",
          importExcelUrl: "api/erp/hr/apply/erpHrApplyRegisterBill/importExcel",
        },
        dictOptions:{},
        superFieldList:[],
      }
    },
    created() {
      this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      //查看详情
      getDetail(id) {
        this.$router.push({
          path: `/erp/hr/apply/ErpHrApplyRegisterBillListDetail/${id}`,
        })
      },
      //处理面试
      handleInterview(applyId,step){
        this.$refs.applyInfo.add(applyId,step);
      },
      initDictConfig(){
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'string',value:'name',text:'姓名',dictCode:''})
        fieldList.push({type:'string',value:'gender',text:'性别',dictCode:''})
        fieldList.push({type:'string',value:'national',text:'名族',dictCode:''})
        fieldList.push({type:'sel_search',value:'nativePlace',text:'籍贯',dictTable:'', dictText:'', dictCode:''})
        fieldList.push({type:'date',value:'birthDate',text:'出生日期'})
        fieldList.push({type:'string',value:'idCardNo',text:'身份证号',dictCode:''})
        fieldList.push({type:'string',value:'workTime',text:'工作年限',dictCode:''})
        fieldList.push({type:'string',value:'maritalStatus',text:'婚姻状况',dictCode:''})
        fieldList.push({type:'string',value:'height',text:'身高',dictCode:''})
        fieldList.push({type:'string',value:'politicalLandscape',text:'政治面貌',dictCode:''})
        fieldList.push({type:'string',value:'hasFamilyGeneticHistory',text:'是否有家族遗传病',dictCode:''})
        fieldList.push({type:'string',value:'geneticHistory',text:'是否有传染病史',dictCode:''})
        fieldList.push({type:'string',value:'bloodType',text:'血型',dictCode:''})
        fieldList.push({type:'string',value:'hobby',text:'特长和爱好',dictCode:''})
        fieldList.push({type:'string',value:'hasPastMedicalHistory',text:'是否有既往病史',dictCode:''})
        fieldList.push({type:'string',value:'hasCriminalRecord',text:'是否有犯罪记录',dictCode:''})
        fieldList.push({type:'sel_search',value:'applyPosition',text:'应聘岗位',dictTable:'', dictText:'', dictCode:''})
        fieldList.push({type:'string',value:'expectedSalary',text:'期望薪资（元）',dictCode:''})
        fieldList.push({type:'string',value:'expectedWorkAddress',text:'期望工作地点',dictCode:''})
        fieldList.push({type:'string',value:'applyStatus',text:'应聘现况',dictCode:''})
        fieldList.push({type:'date',value:'expectedArrival',text:'预计到岗时间'})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>
